﻿/*
  +++++++++++++++++++++++++++++++++++++++++++
  +  Description: 登录日志 管理
  +  Created by 王大宸 on 2020-10-14 21:47:38
  +  Created with IntelliJ IDEA.
  ++++++++++++++++++++++++++++++++++++++++++++
 */

var path = "/monitor/login/record";
layui.use(['table', 'laypage'], function () {
    table = layui.table;
    layPage = layui.laypage;

    /* 初始化表格 */
    initTable();

    // 搜索
    $.searchTable.searchBtn();

    //监听行工具事件
    table.on('tool(baseLoginRecordLay)', function (obj) {
        let data = obj.data;
        if ('del' === obj.event) {
            let removeUrl = path + '/' + data.id;
            $.http.remove(removeUrl, data.name);
        } else if ('edit' === obj.event) {
            let editUrl = path + '/edit/' + data.id;
            $.modal.open('修改', editUrl, '700', '350');
        } else if ('see' === obj.event) {
            let seeUrl = path + '/see/' + data.id;
            $.modal.see('查看', seeUrl, '700', '350');
        }
    });

});

/* 加载表格 */
function initTable() {
    let name = $("#name").val();
    $.table.init({
        url: path + "/page",
        where: {
            name: name
        },
        cols: [[
            {field: 'loginName', title: '登录账号', align: "center"},
            {field: 'name', title: '姓名', align: "center"},
            {field: 'clientId', title: '客户端',width: 170,  align: "center"},
            {field: 'ipaddr', title: '登录IP地址', align: "center"},
            {field: 'loginLocation', title: '登录地点', align: "center"},
            {field: 'browser', title: '浏览器类型', align: "center"},
            {field: 'os', title: '操作系统', align: "center"},
            {field: 'loginTime', title: '访问时间', align: "center"},
        ]],
    });
}
